package com.softstao.guoyu.base;

import android.content.DialogInterface;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Toast;

import com.wangjie.androidbucket.mvp.ABActivityViewer;
import com.wangjie.androidbucket.mvp.ABBasePresenter;
import com.wangjie.androidinject.annotation.present.AIPresent;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * Created by Administrator on 2016/7/22.
 */
public class ParentFragment extends Fragment implements ABActivityViewer,AIPresent {
    private ABBasePresenter presenter;

    public ParentFragment() {
    }

    public void showToastMessage(String msg) {
        Toast.makeText(this.getActivity(), msg, Toast.LENGTH_SHORT).show();
    }

    public void showInfoDialog(String message) {
        this.showInfoDialog((String)null, message);
    }

    public void showInfoDialog(String title, String message) {
        (new AlertDialog.Builder(this.getActivity())).setTitle(title).setMessage(message).setPositiveButton("OK", (DialogInterface.OnClickListener)null).show();
    }

    public void showLoadingDialog(String message) {
    }

    public void cancelLoadingDialog() {
    }

    public void showInfoDialog(String title, String message, String okButtonText) {
        (new AlertDialog.Builder(this.getActivity())).setTitle(title).setMessage(message).setPositiveButton(okButtonText, (DialogInterface.OnClickListener)null).show();
    }

    public void registerPresenter(ABBasePresenter presenter) {
        this.presenter = presenter;
    }

    public void closeAllTask() {
        if(null != this.presenter) {
            this.presenter.closeAllTask();
        }

    }

    @Override
    public void onInjectFailed(Exception e) {
    }

    @Override
    public void setContentView_(int i) {

    }

    @Override
    public View findViewById_(int i) {
        return null;
    }

    @Override
    public void parserTypeAnnotations(Class aClass) throws Exception {

    }

    @Override
    public void parserMethodAnnotations(Method method) throws Exception {

    }

    @Override
    public void parserFieldAnnotations(Field field) throws Exception {

    }
}
